/**
 *  @file shipDescr.h
 *
 *  @date 23-dec-2009
 *  @author Ives van der Flaas
 */

#ifndef SHIPDESCR_H_
#define SHIPDESCR_H_

#include <string>
#include <tr1/memory>
#include <cassert>
#include "vector2.h"

namespace si
{
/**
 * Lists the type of projectile this ship will fire.
 */
enum ProjectileType { BULLET, SPRAYINGBULLET };

/**
 * Abstract descriptor of the controller that will drive a ship
 */
class ControllerDescr
{
public:
	virtual void IHATECPLUSPLUS(){};
};

/**
 * Description of a linear controller for ships.
 */
class LinearControllerDescr: public ControllerDescr
{
	friend class EnemyShip;
public:
	LinearControllerDescr(Vector2 iSpeed): speed(iSpeed){}
private:
	si::Vector2 speed;
};

/**
 * Description of a controller that goes in a sinusoidal manner for ships.
 */
class SinusoidalControllerDescr: public ControllerDescr
{
	friend class EnemyShip;
public:
	SinusoidalControllerDescr(double iVSpeed, double iSweepWidth): vSpeed(iVSpeed), sweepWidth(iSweepWidth){}
private:
	double vSpeed;
	double sweepWidth;
};

/**
 * Descriptor for a ship.
 */
class ShipDescr
{
public:
	friend class EnemyShip;

	/// empty default ctor that can never be called, needs to exist for usage with std::map
	ShipDescr(){  }
	/**
	 * Ctor
	 * @param iMyName Name of the ship (i.e. "cruiser")
	 * @param iSize Virtual size of the ship
	 * @param iStartHealth Amount of health the ship starts with
	 * @param iFireFreq Once every x seconds the ship has to fire
	 * @param iProj Type of projectile it will fire
	 * @param iController Type of controller driving the ship
	 * @return
	 */
	ShipDescr(
			std::string iMyName,
			Vector2 iSize,
			int iStartHealth,
			double iFireFreq,
			ProjectileType iProj,
			std::tr1::shared_ptr<ControllerDescr> iController):
		myName(iMyName),
		size(iSize),
		startHealth(iStartHealth),
		fireFreq(iFireFreq),
		projType(iProj),
		controller(iController)
	{}

	/**
	 * Gets the name of the ship.
	 * @return
	 */
	std::string getName() const { return myName; }

private:
	std::string myName;
	Vector2 size;
	int startHealth;
	double fireFreq;
	ProjectileType projType;
	std::tr1::shared_ptr<ControllerDescr> controller;

};


}

#endif /* SHIPDESCR_H_ */
